import config from "@/config"
import http from "@/utils/request"
import tool from '@/utils/tool'
const userInfo = tool.data.get(config.USER_INFO_KEY)
export default {
	operators: {
		list: {
			url: `${ config.API_URL }/admin/queryOrgList`,
			name: "运营商列表",
			get: async function(data = {}) {
				return await http.get(this.url, data);
			}
		},
		selectList: {
			url: `${ config.API_URL }/admin/orgSelect`,
			name: "运营商下拉选择列表",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addOrg`,
			name: "添加运营商",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editOrg`,
			name: "修改运营商",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deleteOrg`,
			name: "删除运营商",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		}
	},
	businessPostage: {
		list: {
			url: `${ config.API_URL }/admin/queryPolicyList`,
			name: "资费列表",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		selectListByOrg: {
			url: `${ config.API_URL }/admin/getOrgPolicySelect`,
			name: "根据运营商ID获取资费策略",
			post: async function(data) {
				return await http.post(this.url + '?orgId=' + data.orgId);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addPolicy`,
			name: "添加资费",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editPolicy`,
			name: "修改资费",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deletePolicy`,
			name: "删除资费",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		},
		addOrUpdMotoPrice: {
			url: `${config.API_URL}/admin/addOrUpdMotoPrice`,
			name: "新增或者修改摩托车费率",
			post: async function(data, config = {}) {
				console.log("Sending data:", data);
				try {
					const response = await http.post(this.url, data, config);
					console.log("Response:", response);
					return response;
				} catch (error) {
					console.error("Error:", error);
					throw error;
				}
			}
		},
		getMotoPrice: {
			url: `${ config.API_URL }/admin/getMotoPrice`,
			name: "获取摩托车费率",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		},
		insertTariffPolicy: {
			url: `${ config.API_URL }/admin/insertTariffPolicy`,
			name: "小车尖峰平谷资费新增",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		updateTariffPolicy: {
			url: `${ config.API_URL }/admin/updateTariffPolicy`,
			name: "小车尖峰平谷资费修改",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		getTimeByTariffId: {
			url: `${ config.API_URL }/admin/getTimeByTariffId`,
			name: "小车尖峰平谷资费获取",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		}
	},
	businessStation: {
		list: {
			url: `${ config.API_URL }/admin/queryStationList`,
			name: "站点列表/场点列表",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
				// return await http.post(this.url, data, config);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addStation`,
			name: "添加站点",
			post: async function(data, config = {}) {
				
			
				return await http.post(this.url, data, config);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editStation`,
			name: "修改站点",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deleteStation`,
			name: "删除站点",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		},
		queryStationListByOrgIds: {
			url: `${ config.API_URL }/admin/stationList`,
			name: "根据运营商ID集合获取站点列表",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		getStationList: {
			url: `${ config.API_URL }/admin/getStationList   `,
			name: "根据运营商ID集合获取站点列表",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		uploadStationImage: {
			url: `${ config.API_URL }/admin/uploadStationImage`,
			name: "上传图片",
			post: async function(data, config = {}) {
				return await http.post(this.url,data);
			}
		},
		getStationImgs: {
			url: `${ config.API_URL }/admin/getStationImgs`,
			name: "回显图片",
			post: async function(data, config = {}) {
				return await http.post(this.url,data);
			}
		},
		deleteStationImgs: {
			url: `${ config.API_URL }/admin/deleteStationImgs`,
			name: "删除图片",
			post: async function(data, config = {}) {
				return await http.post(this.url,data);
			}
		}
	},
	businessCharging: {
		list: {
			url: `${ config.API_URL }/admin/queryPilePage`,
			name: "充电桩列表",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addPile`,
			name: "添加充电桩",
			post: async function(data, config = {}) {
				console.log("=======================",data)
				return await http.post(this.url, data, config);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editPile`,
			name: "修改充电桩",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deletePile`,
			name: "删除充电桩",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		},
		uploadFile: {
			url: `${ config.API_URL }/admin/uploadFile`,
			name: "文件上传",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		},
		editGun: {
			url: `${ config.API_URL }/admin/updateGunType`,
			name: "修改抢类型",
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
			// url: `${ config.API_URL }/admin/updateGunType`,
			// name: "修改抢类型",
			// post: async function(data, config={}){
			// 	return await http.post(this.url, data, config);
			// }
		},
		deletePileAdv: {
			url: `${ config.API_URL }/admin/deletePileAdv`,
			name: "delete ADV",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		getPileAdv: {
			url: `${ config.API_URL }/admin/getPileAdv`,
			name: "getPileAdv",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		OTA: {
			url: `${ config.API_URL }/admin/OTA`,
			name: "OTA",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		}


	},
	user: {
		list: {
			url: `${ config.API_URL }/admin/queryUserAccountPage`,
			name: "用户列表",
			post: async function(data) {
				// const config = {
				// 	header: {
				// 		"value": userInfo.token,
				// 		"type": "text"
				// 	}
				// }
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
				// return await http.post(this.url, data, config);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addBusinessUser`,
			name: "添加app用户",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		accountOrder: {
			url: `${ config.API_URL }/admin/getAccountOrder`,
			name: "消费记录",
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		chargeMoney: {
			url: `${ config.API_URL }/admin/chargeMoney`,
			name: "卡充值",
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		updateUserStatus: {
			url: `${ config.API_URL }/admin/updateUserId`,
			name: "更改用户状态（1是正常，2冻结）",
			// get: async function(data={}){
			// 	return await http.get(this.url, data);
			// }
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deleteUserId`,
			name: "删除用户",
			// get: async function(data={}){
			// 	return await http.get(this.url, data);
			// },
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		}
	},
	userCharge: {
		list: {
			url: `${ config.API_URL }/admin/queryByPageChargeRecords`,
			name: "用户充值记录列表",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
	},
	userBind: {
		list: {
			url: `${ config.API_URL }/admin/queryCardPage`,
			name: "用户卡绑定列表",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addCard`,
			name: "用户卡添加",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editCard`,
			name: "用户卡编辑",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deleteCard`,
			name: "删除用户卡",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?cardNo=' + data.cardNo);
			}
		}
	},
	order: {
		list: {
			url: `${ config.API_URL }/admin/queryOrderPage`,
			name: "订单列表",
			post: async function(data, config = {}) {
				console.log(data)
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
				// return await http.post(this.url, data, config);
			}
		},
		settle: {
			url: `${ config.API_URL }/admin/settleChargeOrder`,
			name: "后台结算异常订单(待结算)",
			get: async function(data = {}) {
				return await http.get(this.url, data);
			}
		}
	},
	report: {
		stationReport: {
			url: `${config.API_URL}/admin/stationReport`,
			name: "充电总计报表",
			post: async function(data = {}, config = {}) {
				const body = {
					pageNo: data.pageNo ?? 1,
					pageSize: data.pageSize ?? 10,
					pileSer: data.pileSer || "",
					orgId: data.orgId || "",
					stationId: data.stationId || "",
					startTime: data.startTime || "",
					endTime: data.endTime || "",
					type: data.type
				};
				return await http.post(this.url, body, config);
			}
		},
		accountChargeReport: {
			url: `${ config.API_URL }/admin/accountChargeReport`,
			name: "充值记录报表",
			post: async function(data = {}, config = {}) {
				const body = {
					pageNo: data.pageNo ?? 1,
					pageSize: data.pageSize ?? 10,
					orgId: data.orgId || "",
					startTime: data.startTime || "",
					endTime: data.endTime || "",
					type: data.type
				};
				return await http.post(this.url, body, config);
			}
		}
	},
	systemUser: {
		list: {
			url: `${ config.API_URL }/admin/queryByPageUser`,
			name: "平台帐号列表",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addUser`,
			name: "平台帐号添加",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editUser`,
			name: "平台帐号编辑",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deleteUser`,
			name: "平台帐号删除",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		},
		saveAuth: {
			url: `${ config.API_URL }/admin/saveStationData`,
			name: "保存平台帐号关联运营商和站点",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		query: {
			url: `${ config.API_URL }/admin/queryUser`,
			name: "查询用户信息",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		queryUserOrgRole: {
			url: `${ config.API_URL }/admin/queryUserOrgRole`,
			name: "查询指定用户信息允许选择的运营商+允许选择的角色信息",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		queryLoginUserMenu: {
			url: `${ config.API_URL }/admin/queryLoginUserMenu`,
			name: "查询当前登录用户授权的菜单",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		getCountryAuthorize: {
			url: `${ config.API_URL }/admin/getParamList?type=country`,
			name: "获取国家参数列表",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
	},
	index: {
		agentChargeRecords: {
			url: `${ config.API_URL }/admin/queryChargeRecords`,
			name: "获取注册用户总数",
			post: async function(data, config = {}) {
				return await http.post(this.url);
			}
		},
		allAddUser: {
			url: `${ config.API_URL }/admin/queryAddUser`,
			name: "获取注册用户总数",
			post: async function(data, config = {}) {
				return await http.post(this.url);
			}
		},
		SumAllWhere: {
			url: `${config.API_URL}/admin/querySumAllWhere`,
			name: '统计今天和累计所有的数据',
			post: async function(data = {}, config = {}) {
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}`, {},
					config
				);
			}
		},
		WeekSumWhere: {
			url: `${config.API_URL}/admin/queryWeekSumWhere`,
			name: '统计-一周数据',
			post: async function(data = {}, config = {}) {
				console.log('data', data)
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				const type = data.type ?? '';
				const beginDate = data.beginDate ?? '';
				const endDate = data.endDate ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}&type=${type}&beginDate=${beginDate}&endDate=${endDate}`, {},
					config
				);
			}
		},
		querySumRfidCharge: {
			url: `${config.API_URL}/admin/querySumRfidCharge`,
			name: '统计-一周数据-钱包',
			post: async function(data = {}, config = {}) {
				// console.log('data', data)
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				const type = data.type ?? '';
				const beginDate = data.beginDate ?? '';
				const endDate = data.endDate ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}&type=${type}&beginDate=${beginDate}&endDate=${endDate}`, {},
					config
				);
			}
		},
		indexQuerySum: {
			url: `${config.API_URL}/admin/querySum`,
			name: '后台首页电量以及金额统计',
			// post: async function(data, config = {}) {
			// 	return await http.post(this.url, data, config);
			// }
			post: async function(data = {}, config = {}) {
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				const type = data.type ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}&type=${type}`, {}, // ③ POST body 留空
					config
				);
			}
		},
		ChargeGunCount: {
			url: `${config.API_URL}/admin/queryChargeGunCount`,
			name: '后台首页抢数量统计',
			post: async function(data = {}, config = {}) {
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}`, {}, // ③ POST body 留空
					config
				);
			}
		},
		ChargePileCount: {
			url: `${config.API_URL}/admin/queryChargePileCount`,
			name: '后台桩数量统计',
			post: async function(data = {}, config = {}) {
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}`, {},
					config
				);
			}
		},
		queryAddUserOrg: {
			url: `${config.API_URL}/admin/queryAddUser`,
			name: '运营商详情',
			post: async function(data = {}, config = {}) {
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}`, {},
					config
				);
			}
		},
		AllStationCount: {
			url: `${config.API_URL}/admin/queryAllStationCount`,
			name: '后台首页站数量统计',
			post: async function(data = {}, config = {}) {
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}`, {},
					config
				);
			}
		},
		querySumTimeKwh: {
			url: `${config.API_URL}/admin/querySumTimeKwh`,
			name: '尖峰平谷电量统计',
			post: async function(data = {}, config = {}) {
				const orgId = data.orgId ?? '';
				const stationId = data.stationId ?? '';
				return await http.post(
					`${this.url}?orgId=${orgId}&stationId=${stationId}`, {},
					config
				);
			}
		}
	},
	notification: {
		insertNotifications: {
			url: `${config.API_URL}/admin/insertNotification`,
			post: async function(data) {
					const body = { title: data.title, content: data.content };
				return await http.post(this.url, body, config);
			}
		},
		updateNotifications: {
			url: `${ config.API_URL }/admin/updateNotification`,
			name: "编辑用户通知",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		deleteNotifications: {
			url: `${ config.API_URL }/admin/deleteNotification`,
			name: "删除用户通知",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		},
		queryNotificationList: {
			url: `${ config.API_URL }/admin/queryNotificationByPage`,
			name: "查询通知列表",
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		sendNotification: {
			url: `${ config.API_URL }/admin/sendNotificationMsg`,
			name: "下发通知",
			post: async function(data) {
				return await http.post(this.url, data, config);
			}
		}
	},
	systemAccount: {
		list: {
			url: `${ config.API_URL }/admin/queryRolePage`,
			name: "角色列表",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addRole`,
			name: "添加角色",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editRole`,
			name: "编辑角色",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deleteRole`,
			name: "删除角色",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		},
		selectList: {
			url: `${ config.API_URL }/admin/queryRoles`,
			name: "角色下拉选择列表",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		savaMenuRoleAuth: {
			url: `${ config.API_URL }/admin/savaMenuRoleAuth`,
			name: "设置角色权限",
			post: async function(data, config = {}) {
				return await http.post(this.url, data, config);
			}
		},
		// queryMenuRoleAuth: {
		// 	url: `${ config.API_URL }/admin/menuRoleTree`,
		// 	name: "查询角色权限",
		// 	post: async function(data){
		// 		const urlParams = new URLSearchParams(data).toString();
		// 		const fullUrl = this.url + `?${urlParams}`
		// 		return await http.post(fullUrl);
		// 	}
		// }
	},
	// systemMenus: {
	// 	list: {
	// 		url: `${ config.API_URL }/admin/menuRoleTree`,
	// 		name: "菜单列表，由于这里没有data，message层级，直接调用的$HTTP方法",
	// 		post: async function(data, config={}){
	// 			return await http.post(this.url, data, config);
	// 		}
	// 	},
	// },
	systemParams: {
		list: {
			url: `${ config.API_URL }/admin/getParamList`,
			name: "平台参数列表",
			post: async function(data, config = {}) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
				// return await http.post(this.url, data, config);
			}
		},
		add: {
			url: `${ config.API_URL }/admin/addParam`,
			name: "添加参数",
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		edit: {
			url: `${ config.API_URL }/admin/editParam`,
			name: "编辑参数",
			post: async function(data) {
				const urlParams = new URLSearchParams(data).toString();
				const fullUrl = this.url + `?${urlParams}`
				return await http.post(fullUrl);
			}
		},
		delete: {
			url: `${ config.API_URL }/admin/deleteParam`,
			name: "删除参数",
			post: async function(data, config = {}) {
				return await http.post(this.url + '?id=' + data.id);
			}
		}
	}
}
